<html>
    <head>
        <meta charset="UTF-8">
        <title>innerHTML,innerText</title>
        <script type="text/javascript">
            function testInnerHTML(){
                var div1 = document.getElementById("div1");
                //innerHTML:将后面的字符串当作HTML代码解释并且执行。
                div1.innerHTML = "<font color='red'>test</font>";
            }
            function testInnerText(){
                var div2 = document.getElementById("div2");
                //innerText：即使后面指定的字符串是HTML代码，也只是当作普通字符串来输出。
                div2.innerText = "<font color='red'>test</font>";
                div2.textContent = "<font color='red'>test</font>";
            }
            
            
        </script>
    </head>
    <body>
        <input type="button" value="div1" onclick="testInnerHTML();"/>
        <div id="div1"></div>
        <hr>

        <input type="button" value="div2" onclick="testInnerText();"/>
        <div id="div2"></div>
    </body>
</html>